package day2;

public class zy1 {
    public static void main(String[] args) {
        String s= "This is good dog dog";
        String s1 = "dog";
        int a=0;
        int a1=0;
        while ((a1=s.indexOf(s1, a1)) != -1){
            a++;
            a1=a1+s1.length();
        }
        System.out.println(s1+"出现了"+a+"次");
    }
}
